<?php
namespace backend\controllers;

use Yii;
use yii\web\Controller;
use yii\filters\VerbFilter;
use yii\filters\AccessControl;
use common\models\LoginForm;
use yii\uploadfile\UploadFile;
/**
 * Site controller
 */
class SiteController extends Controller
{
    public $enableCsrfValidation = false;
   public function actionA(){
       echo 111;
   }

   public function actionUpload(){
       $data = Yii::$app->request->post();
       $upload = new UploadFile();// 实例化上传类
       $upload->exts = array('jpg', 'gif', 'png', 'jpeg');// 设置附件上传类型
       $upload->savePath = '../../public/uploads/'; // 设置附件上传根目录
       if (!is_dir($upload->savePath)) {  //判断是否创建了存放上传图片的文件夹
           mkdir($upload->savePath, 0777, true);
       }
       // 上传文件
       $info = $upload->upload();
       if (!$info) {// 上传错误提示错误信息
           return "";
       } else {// 上传成功
           $result = $upload->getUploadFileInfo();
           $big_img = '/public/uploads/'.$result[0]['savename'];
           $data['flag'] = 1;
           $data['url'] = $big_img;
           return $big_img;
       }
//       return "http://q.qqbiaoqing.com/q/2011-8-3/e073d7d5955d57c30dc6d0d37210e470.gif";
   }
}
